
package com.yuke.cloud.service.opc.controller.rpc;

import com.yuke.cloud.common.core.support.BaseController;
import com.yuke.cloud.common.util.wrapper.WrapMapper;
import com.yuke.cloud.common.util.wrapper.Wrapper;
import com.yuke.cloud.service.api.opc.dto.gaode.GaodeLocation;
import com.yuke.cloud.service.api.opc.service.OpcGaodeFeignApi;
import com.yuke.cloud.service.opc.utils.GaoDeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * The class Opc attachment feign client.
 *
 * @author
 */
@RestController
@RequestMapping
@Api(value = "API - OpcGaodeFeignClient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OpcGaodeFeignClient extends BaseController implements OpcGaodeFeignApi {

	@Override
	@ApiOperation(httpMethod = "POST", value = "根据IP获取位置信息")
	public Wrapper<GaodeLocation> getLocationByIpAddr(@RequestParam("ipAddr") String ipAddr) {
		String temp = "127.0.";
		String temp2 = "192.168.";
		if (ipAddr.startsWith(temp) || ipAddr.startsWith(temp2)) {
			ipAddr = "111.199.188.14";
		}
		return WrapMapper.ok(GaoDeUtil.getCityByIpAddr(ipAddr));
	}

	@Override
	@ApiOperation(httpMethod = "GET", value = "根据地址获取经纬度")
	public Wrapper<Map> getLonLarByAddr(@RequestParam("addr") String addr, @RequestParam("city") String city) {
		return WrapMapper.ok(GaoDeUtil.getLonLarByAddress(addr, city));
	}


}
